package com.rec.smile.mapper;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import com.rec.smile.bo.SecKill;

public interface SecKillMapper {
    int deleteByPrimaryKey(Long id);

    int insert(SecKill record);

    int insertSelective(SecKill record);

    SecKill selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(SecKill record);

    int updateByPrimaryKey(SecKill record);
    
    @Update("update secKill set num = num -1 where id=#{id} and end_time >= #{secKillTime} and start_time <=#{secKillTime} and num >0")
    int reduceSecKillNum(@Param("id") long id,@Param("secKillTime") Date secKillTime);
    
    //@Select("select * from secKill limit #{offset}, #{limit}")
    List<SecKill> queryBy(@Param("offset") int offset, @Param("limit") int limit);
}